home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pasblk.zip
/
PASBLK.DOC
< prev
next >
Wrap
Text File
|
1990-04-28
|
7KB
|
120 lines
PASBLK 1.5
PASBLK.PAS is a TP4/5 program that is designed to help visualize block
structures in Pascal programs. It can be used on either a monochrome
or a color monitor. Blocks are displayed using seven different colors
on a color monitor. On a monochrome monitor four combinations of
intensity and underlining are used to show the blocks.
PASBLK must be compiled with Turbo Pascal 4 or 5 (or modified for Turbo
Pascal 3). Then it may be executed without any parameters on the
command line to get a brief tutorial. When a Pascal program file name
is given on the command line, PASBLK reads the file into memory; at this
same time it searches for blocks and sets pointers to where colors will
change when the lines are displayed. It also expands TABs if it finds
any. When the entire file has been read onto the heap, then it is displayed
with the blocks shown in their different colors and with comment fields
shown in reverse video in the color of the block they fall into. The
cursor up/down keys may be used to scroll the display forward or backward,
and the PgUp, PgDn, Home, and End keys also work as usual. The Esc key
terminates the program.
As part of its operation, PASBLK performs the following functions.
1.) The video mode is checked before any file I/O is begun to
determine whether to use monochrome or color attributes.
2.) The display color in effect when PASBLK first loads is saved and
restored at termination.
3.) The block nesting depth is monitored, and if it does not return to
zero at the end-of-file, a warning is given; NOTE: not all block
nesting errors can be caught by the simple method of counting
opening and closing block keywords; there may be the same number
of openings and closings with block structures overlapping each
other, and the UNIT..END block may or may not have a BEGIN for
initialization code. For the last case, PASBLK assumes that if it
has seen a UNIT keyword and if the block nesting error is +1, then
it is because a BEGIN for initialization code was present, so it
is not an error, and no warning is given. It is beyond PASBLK's
scope to attempt to see whether the leftover nesting level could
be explained by a BEGIN for initialization code.
4.) A status-line area is given at the top of the screen; this shows the
file name (with any leading path clipped off), the current line range
(numbered according to the original file's lines, not counting wrapped
lines as more than one line), the total number of lines in the file,
and a reminder of which keys may be used to scroll or exit.
5.) The file name is assumed to have an extension of ".PAS" if none is
given; if the desired file name has no extension, it must be given
with a period at the end.
6.) A simple "state-machine" approach is used to keep comments and
literal strings from confusing the identification of block keywords;
the states are 0 (not in comment or string), 1 (in a string delimited
by single-quote marks), 3 (in a comment delimited by "(*" and "*)"),
and 4 (in a comment delimited by "{" and "}").
7.) Lines longer than 80 characters are checked to see whether wrapping
will split a word; if so, blanks are inserted in front of the word that
would be split to keep from splitting it, provided a place to insert a
blank can be found in the last 40 columns. This is done so that keywords
won't be missed due to splitting; lines longer than 160 characters are
treated the same way; insertion of blanks may push characters out the end
of the 255-character string variable; if this happens, or if no place to
insert a blank can be found in the last 40 columns to split the line, a
warning is given, since a block nesting error may result, and in the case
where the line is shifted beyond the 255-character limit, some information
is lost. Extremely long lines are usually not a good idea, anyway.
PASBLK is limited to 2500 display lines (counting wrapped lines as more
than one line) and 20 color changes per line; the limit on lines may be
lower if less than 300K is available on the heap.
Seeing the blocks in different colors may help to find bugs in block nesting,
and having the comments in reverse video helps to find accidentally unclosed
comments that "eat" code and cause errors. If nothing else, the colored
blocks are pretty to look at (just like the colored blocks most of us had as
children!)
Besides unbalanced comment delimiters, unbalanced quote marks are also a
common error that will cause PASBLK to warn of nesting errors. If this
happens, look for the missing quote mark inside any block whose closing
delimiter appears to have been ignored (for example, an END that is followed
by text in the same color).
PASBLK is distributed free of charge subject to the following condition:
it may not be sold or used in any way that requires payment for its use.
ACKNOWLEDGMENT
The author would like to thank Ron Schuster for identifying and helping to
fix two bugs in previous versions of PASBLK, and also for providing the
motivation, information, and most of the coding to make PASBLK work on
monochrome systems. Ron also contributed to this new version by identifying
a manufacturer-dependent quirk in EGA behavior and by uncovering a deficiency
in the expanded blank-insertion logic.
CHANGES IN THIS VERSION
Version 1.4 would hang if it encountered an input line with a length greater
than 80 columns and containing no blanks or blanks only at the beginning of
the line; this has been fixed in version 1.5, which also has more generalized
code for finding a place to split lines without splitting keywords.
This version scrolls faster when the PgUp or PgDn key is held down; the
previous version would "coast", i.e., continue scrolling until it was caught
up with buffered keystrokes. This version uses a WordStar-like approach,
i.e., it does not complete painting the screen until it has caught up with
any buffered keystrokes.
This version is better at restoring the screen attributes that existed prior
to its execution; this affects only certain display systems with behavior that
was not completely taken into account in the previous version.
This version handles OBJECT blocks. Note that TP5.5 is NOT required to
compile PASBLK, however.